package eleven;

import java.io.*;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;

public class UDPTalkClient {
    public static void main(String[] args) throws Exception {
        System.out.println("UDPClient启动中...");
        DatagramSocket client = new DatagramSocket(8888);
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while(true) {
            String baos = reader.readLine();
            byte[] datas = baos.getBytes();
            DatagramPacket packet = new DatagramPacket(datas, 0, datas.length,
                    new InetSocketAddress("localhost", 9999));
            client.send(packet);
            if(baos.equals("bye")){
                break;
            }
        }
        client.close();
    }
}
